//-----------------------------------------------------------------------------
// Archivo: 			 test.c
// Fecha de creación:            20/01/2011
// Ultima fecha de modificación: 15/02/2011
// Diseñador: 			 Jesús Pérez
// Diseño: 			 vector_register_file
// Propósito: 			 Prueba de archivo de registros vectorial 
//				 para el microprocesador vectorial
//-----------------------------------------------------------------------------

#include <stdio.h>
#include "genpat.h"

char* inttostr(int entier) {
  char* str;
  str = (char *) mbkalloc (32 * sizeof(char));
  sprintf(str,"%d",entier);
  return(str);
}

main() {
 
  DEF_GENPAT("test");

  DECLAR("CLK_i"             ,":2","B", IN   ,	""            , "");
  DECLAR("WRITE_ENABLE_i"    ,":2","B", IN   ,	""            , "");
  DECLAR("DATA_i"            ,":2","B", IN   ,	"3 downto 0"  , "");  
  DECLAR("RA_i"              ,":2","B", IN   ,	"1 downto 0"  , "");
  DECLAR("RB_i"              ,":2","B", IN   ,	"1 downto 0"  , "");
  DECLAR("RD_i"              ,":2","B", IN   ,	"1 downto 0"  , "");
  DECLAR("CA_i"              ,":2","B", IN   ,	"1 downto 0"  , "");
  DECLAR("CB_i"              ,":2","B", IN   ,	"1 downto 0"  , "");
  DECLAR("CD_i"              ,":2","B", IN   ,	"1 downto 0"  , "");
  DECLAR("READ_DATA1_o"      ,":2","B", OUT  ,	"3 downto 0"  , "");
  DECLAR("READ_DATA2_o"      ,":2","B", OUT  ,	"3 downto 0"  , "");
  DECLAR("vdd"               ,":2","B", IN   ,	""            , "");
  DECLAR("vss"               ,":2","B", IN   ,	""            , "");

  LABEL("registerfile");
  
  SETTUNIT("ns");
  AFFECT("0" , "vdd"	, "1"); 
  AFFECT("0" , "vss"	, "0");
  
  AFFECT("0"    , "CLK_i"           , "1");
  AFFECT("0"    , "RA_i"            , "0b00");
  AFFECT("0"    , "CA_i"            , "0b00");
  AFFECT("0"    , "RB_i"            , "0b00");
  AFFECT("0"    , "CB_i"            , "0b00");
  AFFECT("0"    , "RD_i"            , "0b00");
  AFFECT("0"    , "CD_i"            , "0b00");
  AFFECT("0"    , "DATA_i"          , "0b0000");
  AFFECT("0"    , "WRITE_ENABLE_i"  , "0");  
    
  AFFECT("+50"  , "CLK_i"           , "0");

  AFFECT("+50"  , "CLK_i"           , "1");
  AFFECT("+0"   , "WRITE_ENABLE_i"  , "1");  
    
  AFFECT("+50"  , "CLK_i"           , "0");

  AFFECT("+50"  , "CLK_i"           , "1");
  AFFECT("+0"   , "RD_i"            , "0b00");
  AFFECT("+0"   , "CD_i"            , "0b01");
  AFFECT("+0"   , "DATA_i"          , "0b1000");
      
  AFFECT("+50"  , "CLK_i"           , "0");

  AFFECT("+50"  , "CLK_i"           , "1");
  AFFECT("+0"   , "RD_i"            , "0b01");
  AFFECT("+0"   , "CD_i"            , "0b11");
  AFFECT("+0"   , "DATA_i"          , "0b1001");
  
  AFFECT("+50"  , "CLK_i"           , "0");

  AFFECT("+50"  , "CLK_i"           , "1");
  AFFECT("+0"   , "RA_i"            , "0b00");
  AFFECT("+0"   , "CA_i"            , "0b01");
  AFFECT("+0"   , "RB_i"            , "0b01");
  AFFECT("+0"   , "CB_i"            , "0b11");
  AFFECT("+0"   , "DATA_i"          , "0b0101");
  AFFECT("+0"   , "WRITE_ENABLE_i"  , "0");

  AFFECT("+50"  , "CLK_i"           , "0");

  AFFECT("+50"  , "CLK_i"           , "1");
  AFFECT("+0"   , "RD_i"            , "0b10");
  AFFECT("+0"   , "CD_i"            , "0b11");
  AFFECT("+0"   , "DATA_i"          , "0b0110");
  AFFECT("+0"   , "WRITE_ENABLE_i"  , "1");

  AFFECT("+50"  , "CLK_i"           , "0");

  AFFECT("+50"  , "CLK_i"           , "1");
  AFFECT("+0"   , "RD_i"            , "0b11");
  AFFECT("+0"   , "CD_i"            , "0b00");
  AFFECT("+0"   , "DATA_i"          , "0b1110");
  
  AFFECT("+50"  , "CLK_i"           , "0");

  AFFECT("+50"  , "CLK_i"           , "1");
  AFFECT("+0"   , "RA_i"            , "0b10");
  AFFECT("+0"   , "CA_i"            , "0b11");
  AFFECT("+0"   , "RB_i"            , "0b11");
  AFFECT("+0"   , "CB_i"            , "0b00");
  AFFECT("+0"   , "RD_i"            , "0b00");
  AFFECT("+0"   , "CD_i"            , "0b00");
  AFFECT("+0"   , "DATA_i"          , "0b1111");
  
  AFFECT("+50"  , "CLK_i"           , "0");

  AFFECT("+50"  , "CLK_i"           , "1");
  AFFECT("+0"   , "RB_i"            , "0b00");
  AFFECT("+0"   , "CB_i"            , "0b01");
  
  AFFECT("+50"  , "CLK_i"           , "0");

  SAV_GENPAT();

  exit(0);
}

